<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../img/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../img/jquery.js" ></script>
<script src="../js/ckeditor/ckeditor.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/ckeditor/ckfinder/ckfinder.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swf/fileprogress.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swf/swfupload.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swf/swfupload.queue.js" type="text/javascript" charset="utf-8"></script>
<script language="javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<script src="../js/jcrop/jquery.Jcrop.js"></script>
<script src="../js/swfhander.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="../js/jcrop/jquery.Jcrop.css" type="text/css" />
<script language="javascript">
    function checkSubmit()
    {
      if(document.form1.product_name.value == '')
      {
	       alert("请填写产品名称！");
	       return false;
      }  
    }   
</script>
</head>
<body leftmargin='15' topmargin='10' bgcolor="#FFFFFF">
   <form name="form1" action="product_act.php?action=save" enctype="multipart/form-data" method="post" onSubmit="return checkSubmit()">
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	    <td>&nbsp;</td>
	</tr>
    </table>

    <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" id="head1" style="border-bottom:1px solid #CCCCCC">
	<tr>
	    <td colspan="2">
		<table width="98%" border="0" cellpadding="0" cellspacing="0">
		    <tr>
			<td width="84" height="24" align="center" background="../img/itemnote1.gif">&nbsp;编辑产品&nbsp;</td>
			<td width="84"></td>
			<td>&nbsp;</td>
		    </tr>
		</table>
	    </td>
	</tr>
    </table>

    <table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">
	<tr>
	    <td height="24" colspan="4" class="bline">
			<table width="98%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td class="bline logo_box_larg">&nbsp;产品小标题：</td>
					<td class="bline"><input name="product_id" type="hidden" value="<{$product_arr.product_id}>"/><input name="product_name" type="text" value="<{$product_arr.product_name}>"  size="30" class="iptxt" /><span style="color:#F00">*必填</span></td>
					<td class="bline"  width="110"></td>
					<td class="bline" width="300" align="right" rowspan="5">
						<div id=logo_box >
							<{if $product_arr.logo neq ''}>
								<input type="hidden"  name="logo" size="40" value="<{$product_arr.logo}>"/><div class="img_box"><img id="jcrop_img"  src="../upload/product/<{$product_arr.logo}>"/></div>
							<{/if}>
						</div>
					</td>
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;产品长标题：</td>
					<td class="bline">
						<input name="product_title"  value="<{$product_arr.product_title}>" size="90" class="iptxt"/>
					</td>
					<td class="bline"></td>
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;产品状态：</td>
					<td class="bline">
						<select name="status">
							   <option 	<{if $product_arr.status eq 0}>selected="selected"<{/if}> value="0">待审</option>
							   <option 	<{if $product_arr.status eq 1}>selected="selected"<{/if}> value="1">审核通过</option>
							   <option 	<{if $product_arr.status eq 2}>selected="selected"<{/if}> value="2">审核不通过</option>
						</select>
					</td>
					<td class="bline"></td>
				</tr>
				 <tr>
					<td class="bline" width="90">&nbsp;产品类别：</td>
					<td class="bline">
						<select name="product_type_id">
							<{foreach item=type_arr from=$typelist}>
							   <option 	<{if $product_arr.product_type_id eq $type_arr['product_type_id']}>selected="selected"<{/if}> value="<{$type_arr['product_type_id']}>"><{$type_arr['product_type_name']}></option>
							<{/foreach}>
						</select>
					</td>
					<td class="bline"></td>
				</tr>				
				<tr>
					<td class="bline" width="90">&nbsp;产品所在城市：</td>
					<td class="bline">
						<select name="city_id">
							<{foreach item=districtlist_arr from=$districtlist}>
							   <option <{if $product_arr.city_id eq $districtlist_arr['id']}>selected="selected"<{/if}> value="<{$districtlist_arr['id']}>"><{$districtlist_arr['name']}></option>
							<{/foreach}>
						</select>
					</td>
					<td class="bline"></td>
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;产品客户群：</td>
					<td class="bline">
						<input type="radio" name="product_belong" <{if $product_arr.product_belong eq 2}>checked<{/if}> value = "2">公众产品 &nbsp;
						<input type="radio" name="product_belong" <{if $product_arr.product_belong eq 1}>checked<{/if}> value = "1">经销商产品
					</td>
					<td class="bline"></td>
					<td class="bline" align="center"  >
					    <div class="fieldset flash" style="padding-left: 15px;display:none;"  id="fsUploadProgress1"> </div>
					    <span id="spanButtonPlaceholder1"></span>
                        <input id="btnCancel1" type="hidden" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
						<span id="upload_id" style="cursor: pointer;">上传</span>&nbsp;&nbsp;
						<span id="cut_id"  style="line-height: 28px;">裁切</span>
					</td>
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;现价：</td>
					<td class="bline"  ><input name="product_price"  value="<{$product_arr.product_price}>" size="30" class="iptxt"/></td>
					<td class="bline" width="90">&nbsp;产品来源：</td>
					<td class="bline"><input name="product_source" value="<{$product_arr.product_source}>" size="30" class="iptxt"/></td>
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;成团人数：</td>
					<td class="bline"><input name="group_count" value="<{$product_arr.group_count}>" size="30" class="iptxt"/></td>					
					<td class="bline" width="90">&nbsp;销售量：</td>
					<td class="bline"><input name="product_sell_count" value="<{$product_arr.product_sell_count}>" size="30" class="iptxt"/></td>				
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;团购价：</td>
					<td class="bline"  ><input name="product_group_price"  value="<{$product_arr.product_group_price}>" size="30" class="iptxt"/></td>
					<td class="bline" width="90">&nbsp;浏览量：</td>
					<td class="bline" ><input name="product_looks"  value="<{$product_arr.product_looks}>" size="30" class="iptxt"/></td>
					
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;预约价：</td>
					<td class="bline"  ><input name="book_price"  value="<{$product_arr.book_price}>" size="30" class="iptxt"/></td>
					<td class="bline" width="90">&nbsp;可预约开始时间：</td>
					<td class="bline" ><input name="book_strat_time" onclick="WdatePicker()"  value="<{$product_arr.book_strat_time|date_format:'%Y-%m-%d'}>" size="30" class="iptxt"/></td>					
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;经销商价：</td>
					<td class="bline"  ><input name="sell_one"  value="<{$product_arr.sell_one}>" size="30" class="iptxt"/></td>
					<td class="bline" width="90">&nbsp;可预约结束时间：</td>
					<td class="bline"  ><input name="book_end_time" onclick="WdatePicker()"  value="<{$product_arr.book_end_time|date_format:'%Y-%m-%d'}>" size="30" class="iptxt"/></td>

				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;名企会员价：</td>
					<td class="bline"  ><input name="company_price"  value="<{$product_arr.company_price}>" size="30" class="iptxt"/></td>
					<td class="bline" width="90">&nbsp;报警数量：</td>
					<td class="bline"><input name="warning_count"  value="<{$product_arr.warning_count}>" size="30" class="iptxt"/></td>
				
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;配额：</td>
					<td class="bline"><input name="product_count"  value="<{$product_arr.product_count}>" size="30" class="iptxt"/></td>
					<td class="bline" width="90">&nbsp;</td>
					<td class="bline"  ></td>
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;产品地理位置：</td>
					<td class="bline"  colspan="3"><input name="product_address"  value="<{$product_arr.product_address}>" size="100" class="iptxt"/></td>
					
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;页面标题：</td>
					<td class="bline"  colspan="3"><input name="page_title"  value="<{$product_arr.page_title}>" size="100" class="iptxt"/></td>
					
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;页面关键字：</td>
					<td class="bline"  colspan="3"><input name="page_keyword"  value="<{$product_arr.page_keyword}>" size="100" class="iptxt"/></td>
					
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;页面摘要：</td>
					<td class="bline"  colspan="3"><input name="page_des"  value="<{$product_arr.page_des}>" size="100" class="iptxt"/> </td>
				
				</tr>
				<tr>
					<td class="bline" width="90">&nbsp;内容：</td>
					<td class="bline" colspan="3"> <textarea  class="ckeditor" name="product_content"> <{$product_arr.page_des}></textarea></td>
				</tr>
				<tr>
					<td class="bline" rowspan="2" width="90">&nbsp;产品图片：</td>
					<td class="bline" colspan="3">
						<div id="product_img_list">						
							<{foreach item=imglist from=$img_list}>
								<div class="product_img_box" id="img_box_byi<{$i}>">
									<img  src="../upload/productimg/<{$imglist.product_imgs}>" />
									<div class="img_title">										
										<span class='del_text'  onclick='cut_img("img_box_byi<{$i++}>","../upload/productimg/<{$imglist.product_imgs}>")'>裁切</span>&nbsp;
										<span class="del_text" onclick='delimg(this,"<{$imglist.product_imgs}>","todo")' >删除</span>
									</div>
									<input name="product_imgs[]" type="hidden"  value="<{$imglist.product_imgs}>"/>
								</div>
							 <{/foreach}>							 
						</div>
						<div class="fieldset flash" style="padding-left: 15px;display:none;"  id="fsUploadProgress2"> </div>
					    <span id="spanButtonPlaceholder2"></span>
                        <input id="btnCancel2" type="hidden" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
						
					</td>
				</tr>
				<tr>					
					<td class="bline" colspan="4">
						 <span id="upload_id2" style="cursor: pointer; ">上传</span>&nbsp;&nbsp;
					</td>
				</tr>
			</table>
	    </td>				
	</tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td height="56">
			<table width="98%" border="0" cellspacing="1" cellpadding="1">
				<tr>
				<td align="center">
					<table width="214" border="0" cellspacing="0" cellpadding="0" >
					<tr>
						<td width="115">
						<input name="imageField" type="image" src="../img/button_ok.gif" width="60" height="22" class="np" border="0"  style="cursor:pointer; ">
						</td>
						<td width="99">
						 <img src="../img/button_reset.gif" width="60" height="22" border="0" onClick="location.reload();" style="cursor:pointer; ">
						</td>
					</tr>
				   </table>
				</td>
				</tr>
			</table>
			</td>
		</tr>
    </table>
    </form>
	<div id="jcrop_id" class="jcrop_box" style="width:100%;height:1500px;" >
		<div id="jcrop_img_box"></div>	
		<div><div id="close_jcrop">关闭</div>
		<div id="sure_jcrop">&nbsp;&nbsp;&nbsp;&nbsp;确定裁切</div>
		<div id="sure_jcrop2">&nbsp;&nbsp;&nbsp;&nbsp;确定裁切</div>
			
	</div>
	<input type="hidden" id="left_x"/>
	<input type="hidden" id="left_y"/>
	<input type="hidden" id="bot_x"/>
	<input type="hidden" id="bot_y"/>
	</div>
</body>
</html>
<script type="text/javascript">
	 function cut_img(box_id, src){
			$("#sure_jcrop").hide();
			$("#sure_jcrop2").show();
			$("#jcrop_id").show();
			$html = '<img id="cropboxs"  src="'+src+'"/><input  type="hidden" id="img_src" value="'+src+'"/><input type="hidden" id=box_id value="'+box_id+'"/>';
			$("#jcrop_img_box").empty().append($html);
			var api = $.Jcrop('#cropboxs',{
				 minSize: [940,400],				
				onChange:showCoords,
				onSelect:showCoords,
				setSelect: [10,10,940,400]
			});
	  }

	   $("#sure_jcrop2").click(function(){
			var img_source = $("#cropboxs").attr("src");
			var box_id     = $("#box_id").val();			
			$.post(
				'jcrop2.php',
				{left_x:$("#left_x").val(),left_y:$("#left_y").val(),bot_x:$("#bot_x").val(),bot_y:$("#bot_y").val(),img_src:img_source},
				function(callback){
					var img_name = callback.substr(callback.lastIndexOf('/') + 1);
					$("#jcrop_img_box").empty();
					$("#jcrop_id").hide();
					var cut_img = '<img  src="'+callback+'"/><div class="img_title"><span class="del_text"  onclick=cut_img("'+box_id+'","'+callback+'")>载切</span>&nbsp;<span class="del_text" onclick=delimg(this,"'+callback+'","0")>删除</span></div><input type="hidden" name="product_imgs[]"  value="'+img_name+'"/>';

				    $("#"+box_id).empty().append(cut_img)
				},
				'html'
			);
	  })

	 // ##########################################################################
	  $(function(){	 
		$("#cut_id").click(function(){			
	    	$("#sure_jcrop2").hide();
			$("#sure_jcrop").show();
			$("#jcrop_id").show();
			var jcrop_img_src = $("#jcrop_img").attr("src");
			$html = '<img id="cropbox"  src="'+jcrop_img_src+'">';				
			$("#jcrop_img_box").empty().append($html);
				$.Jcrop('#cropbox',{
				minSize: [0,0],
				handles:true,			
				onChange:showCoords,
				onSelect:showCoords,
				setSelect: [0,0,310,174]
			});
		})

		$("#close_jcrop").click(function(){
			$("#jcrop_img_box").empty();
			$("#jcrop_id").hide();			
		})
      })

	  function showCoords(c)
	  {
		 $("#left_x").val(c.x);
		 $("#left_y").val(c.y);
		 $("#bot_x").val(c.x2);
		 $("#bot_y").val(c.y2);
	  }
     
	  $("#sure_jcrop").click(function(){
			var img_source = $("#jcrop_img").attr("src");				
			$.post(
				'jcrop.php',
				{left_x:$("#left_x").val(),left_y:$("#left_y").val(),bot_x:$("#bot_x").val(),bot_y:$("#bot_y").val(),img_src:img_source},
				function(callback){
					var img_name = callback.substr(callback.lastIndexOf('/') + 1);					
					$("#jcrop_img_box").empty();
					$("#jcrop_id").hide();
					$("#logo_box").empty();
					var small_box='<div class="img_box"><img id="jcrop_img"  src="'+callback+'"/><input type="hidden"  name="logo" size="40" value="'+img_name+'"/></div>';
			        $("#logo_box").empty().append(small_box)					
				},
				'html'
			)
	  });
	
</script>